<div>
  <form #formRef="ngForm" (ngSubmit)="on_submit(formRef.value)">
    <fieldset ngModelGroup="login">
      <input type="text"
             placeholder="请输入用户名"
             [(ngModel)]="username"
             name="username"
             minlength="3"
             required
             #usernameRef="ngModel"
      />
      <div *ngIf="usernameRef.errors?.required">需要填写用户名</div>
      <div *ngIf="usernameRef.errors?.minlength">用户名需要至少三个字符</div>
      <br/>

      <input type="password"
             placeholder="请输入密码"
             [(ngModel)]="password"
             name="password"
             required
             #passwordRef="ngModel"
      />
      <div *ngIf="passwordRef.errors?.required">需要填写</div>
    </fieldset>

    <button type="submit">登陆</button>
  </form>

</div>
